<?php 
	require '../db.func.php';
	require 'head.php';
	$cusername=getsession('username','shop');
	$cid=getsession('id','shop');
	$prefix=getprefix();
	if(!empty($cusername)){
		$sql="SELECT products,price,quantity FROM  {$prefix}cart WHERE uid='$cid'";
	    $cart_array=queryone($sql);
	    $cart_products=json_decode($cart_array['products'],true);
	
	}
	
?>

	<div class="body__overlay"></div>
	<!-- Start Offset Wrapper -->
	<div class="offset__wrapper">
		<!-- Start Search Popap -->
		<div class="search__area">
			<div class="container">
				<div class="row">
					<div class="col-md-12">
						<div class="search__inner">
							<form action="#" method="get">
								<input placeholder="Search here... " type="text">
								<button type="submit"></button>
							</form>
							<div class="search__close__btn">
								<span class="search__close__btn_icon"><i class="zmdi zmdi-close"></i></span>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<!-- End Search Popap -->
		<!-- Start Offset MEnu -->
		<div class="offsetmenu">
			<div class="offsetmenu__inner">
				<div class="offsetmenu__close__btn">
					<a href="#"><i class="zmdi zmdi-close"></i></a>
				</div>
				<div class="off__contact">
					<div class="logo">
						<a href="index.html">
							<img src="assets/images/logo/logo.png" alt="logo">
						</a>
					</div>
				</div>
			</div>
		</div>
		<!-- End Offset MEnu -->
		<!-- Start Cart Panel -->
		<?php require 'pan_cart.php'; ?>
		<!-- End Cart Panel -->
	</div>
	<!-- End Offset Wrapper -->

	<div class="cart-main-area bg__white">
		<div class="container">
			<div class="row">
				<div class="col-md-12 col-sm-12 col-xs-12">
					<form action="#">
						<div class="table-content table-responsive">
							<table>
								<thead>
								<tr>
									<th class="product-thumbnail"></th>
									<th class="product-name">商品名称</th>
									<th class="product-price">单价</th>
									<th class="product-quantity">数量</th>
									<th class="product-subtotal">总计</th>
									<th class="product-remove">编辑</th>
								</tr>
								</thead>
								<tbody>
								<?php foreach ($cart_products as $k):?>
								<tr>
									<td class="product-thumbnail"><a href="#"><img src="assets/images/product/4.png" alt="product img" /></a></td>
									<td class="product-name"><a href="#"><?php echo $k['products']['name']; ?></a></td>
									<td class="product-price"><span class="amount"><?php echo $k['products']['price']; ?></span></td>
									<td class="product-quantity"><input type="number" disabled value="<?php echo $k['quantity']; ?>" /></td>
									<td class="product-subtotal">￥<?php echo $k['quantity']*$k['products']['price']; ?></td>
									<td class="product-remove"><a href="cart_del.php?id=<?php echo $k['products']['id'];?>">X</a></td>
								</tr>
								<?php endforeach; ?>
								</tbody>
							</table>
						</div>
						<div class="row">
							<div class="col-md-8 col-sm-7 col-xs-12">
								<div class="buttons-cart">
									<a href="#">继续购物</a>
								</div>

							</div>
							<div class="col-md-4 col-sm-5 col-xs-12">
								<div class="cart_totals">
									<table>
										<tbody>
										<tr class="cart-subtotal">
											<th>小计</th>
											<td><span class="amount">￥<?php echo $cart_array['price'] ;?></span></td>
										</tr>
										<tr class="shipping">
											<th>快递</th>
											<td>
												<ul id="shipping_method">
													<li>
														<input type="radio" checked />
														<label>
															包邮
														</label>
													</li>
													<li></li>
												</ul>
											</td>
										</tr>
										<tr class="order-total">
											<th>总价</th>
											<td>
												<strong><span class="amount">￥<?php echo $cart_array['price'] ;?></span></strong>
											</td>
										</tr>
										</tbody>
									</table>

									<div class="wc-proceed-to-checkout" style="clear: both;">
										<a href="pan_check.php">去付款</a>
									</div>
								</div>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>

	<div class="only-banner ptb--10 bg__white">
	</div>

	<!-- Start Footer Area -->
	<footer class="htc__foooter__area gray-bg">
		<div class="container">

			<!-- Start Copyright Area -->
			<div class="htc__copyright__area">
				<div class="row">
					<div class="col-md-12 col-lg-12 col-sm-12 col-xs-12">
						<div class="copyright__inner">
							<ul class="footer__menu">
								<li><a href="index.html">首页</a></li>
								<li><a href="products.html">所有商品</a></li>
							</ul>
						</div>
					</div>
				</div>
			</div>
			<!-- End Copyright Area -->
		</div>
	</footer>
	<!-- End Footer Area -->
</div>
<!-- Body main wrapper end -->
<!-- Placed js at the end of the document so the pages load faster -->

<!-- jquery latest version -->
<script src="assets/js/vendor/jquery-1.12.0.min.js"></script>
<!-- Bootstrap framework js -->
<script src="assets/js/bootstrap.min.js"></script>
<!-- All js plugins included in this file. -->
<script src="assets/js/plugins.js"></script>
<script src="assets/js/slick.min.js"></script>
<script src="assets/js/owl.carousel.min.js"></script>
<!-- Waypoints.min.js. -->
<script src="assets/js/waypoints.min.js"></script>
<!-- Main js file that contents all jQuery plugins activation. -->
<script src="assets/js/main.js"></script>

</body>

</html>
